package com.atguigu.gmail.config;


import com.atguigu.gmail.interceptors.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//配置类也会作为bean注册到容器中
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
    @Autowired
    AuthInterceptor authInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry){
        /*
        排除要紧跟在后面写，不能另起一行，否则无效
         */
        //页面拦截
        registry.addInterceptor(authInterceptor).addPathPatterns("/**").excludePathPatterns("/error");
        //排除部分页面
//        registry.addInterceptor(authInterceptor).excludePathPatterns("/error");
        super.addInterceptors(registry);
    }
}
